package br.ita.battlefarm.moves;

import br.ita.battlefarm.R;
import br.ita.battlefarm.core.Board;

public class RowMove extends Move {
	public RowMove(){
		_allowedMoves = 1;
		_backgroundRes = R.drawable.shot_row;
		disableMove();
	}

	@Override
	public int fire(Board board, int i, int j) {
		int changeInScore = 0;
		if(hasMovesLeft()){
			if( board.validPlayPosition(i,j) ){
				_allowedMoves--;
				int line = i;
				for(int column = 0; column < board.getNumColumns(); column++){
					changeInScore += fireInSquare(board, line, column);
				}
				if(!hasMovesLeft()){
					disableMove();
				}
			}
		}
		return changeInScore;
	}

}
